<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>万达营销流程管理系统</title>
<link href="../css/css.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="js/ie6png.js" ></script>
<script type="text/javascript">
DD_belatedPNG.fix('div,ul,li,a,p,img,body,dl,dt,dd');</script>

<![endif]-->
<script src="../js/jquery-1.9.1.min.js"></script>
<script> 
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
</script>
<script>
<!--
/*第一种形式 第二种形式 更换显示样式*/
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);
var con=document.getElementById("con_"+name+"_"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}
//-->
</script>
</head>
<body style="background:#fff;">
<form name="form1" id="form1">
<br />
<div style="width:1000px;" class="tbox01 boxcenter">
  <div class="tbox02">
    <dl>
      <dt></dt>
      <dd>
        <div class="tbox02menu">
          <ul>
             <li><a href="#" onclick="addAll()">添加全部</a></li>
            <!--<li><a href="#" onclick="refreshParent()">确定</a></li> -->
          </ul>
        </div>
      </dd>
    </dl>
  </div>
  <div class="tbox03">
    <div class="tbox04a">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="47%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr align="left" valign="top">
                <td><img src="../images/op5_1.gif" /></td>
                <td class="ybox08td2"><ul>
                    待选房间查询
                  </ul></td>
                <td class="ybox08td3"></td>
                <td><img src="../images/op5_4.gif" /></td>
              </tr>
            </table>
            <div class="ybox08div">
              <div class="tbox05 margb7">
                <dl>
                  <dt>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="55" height="25" align="right" style=" padding-right:5px;">楼　栋：</td>
                        <td style=" padding-right:15px;">
                     <select	style="width: 100px">
                     <option value="">---请选择---</option>
	                        <c:forEach items="${complexs}" var="com">
	                        	<option>${com.complexnumber }</option>
	                        </c:forEach>	
                        </select> 
                        </td>
                        <td width="62" rowspan="2"><div class="button26h"><a href="#" onclick="f2()">查询</a> 	</div><div class="button26h"><a href="#" onclick="add()">添加</a> 	</div></td>
                      </tr>
                      <tr>
                        <td height="25" align="right" style=" padding-right:5px;">房间名：</td>
                        <td height="25" style=" padding-right:15px;"><input name="textfield" type="text"  class="black12" id="textfield2"  style="width: 100px"/></td>
                      </tr>
                    </table>
                  </dt>
                </dl>
              </div>
              <table  id="sample-table" width="100%" border="0" align="center" cellpadding="0" cellspacing="1" class="ybox06table">
                <tr>
                  <td width="30" class="ybox06td01"><input type="checkbox" name="checkbox" id="checkbox" onclick="selectall()" /></td>
                  <td width="30" class="ybox06td01">序号</td>
                  <td class="ybox06td01">房间名称</td>
                  <td class="ybox06td01">建筑面积</td>
                  <td class="ybox06td01">套内面积</td>
                </tr>
                <c:forEach items="${rooms }" var="room">
                	 <tr>
                  <td  class="ybox06td02wcenter"><input type="checkbox" name="checkbox1" id="checkbox1" value="${room.id }"/></td>
                  <td class="ybox06td02wcenter">${room.id }</td>
                  <td class="ybox06td02wleft">${room.roomnumber }</td>
                  <td class="ybox06td02wcenter">${room.area }</td>
                  <td class="ybox06td02wcenter">${room.roomprice}</td>
                </tr>
                </c:forEach>
              </table>
            <input type="hidden" value="${zongye}" id="zongye" />
            <input type="hidden" value="${yeshu}" id="yeshu" />
               <div class="nums boxcenter black12"><a href="#" onclick="f2()" class="hovera">首 页</a><a href="#" onclick="f3()">上一页</a><a href="#" onclick="f4()">下一页</a><a class="hovera" href="#" onclick="f5()">尾 页</a>&nbsp;&nbsp;第${yeshu}/${zongye}页&nbsp;共${size }条&nbsp;&nbsp;转到
                <input name="now" type="text" id="now" size="2" value="${yeshu }"/>
                页<a href="#" onclick="f1()">跳 转</a></div>
            </div></td>
        
        </tr>
      </table>
       <input type="hidden" value="${pid}" id="pid" />
    </div>
  </div>
</div>
</form>
</body>
</html>
<script>
	function add(){
		var chk_value =[]; 
		$('input[name="checkbox1"]:checked').each(function(){ 
		chk_value.push($(this).val()); 
		}); 
		//alert(chk_value.length==0 ?'你还没有选择任何内容！':chk_value); 
		
		
		$.ajax({
		    url:"../addroom.do",
		    type:"post",
		    data:{"ids":chk_value},
		    dataType:"json",
		    traditional:true,
		    success:function(data){
		   		
		   	}
		});
		alert("添加成功！");
		location.reload();
	 	 
	
	}
	
	function addAll(){
		var pid = $("#pid").val();
		$.ajax({
		    url:"../addroomAll.do",
		    async: false,
		    type:"post",
		    data:{"pid":pid},
		    dataType:"json",
		    traditional:true,
		    success:function(data){	
		   	}
		});
		alert("添加成功！");
		location.reload();
	}


	function f1(){
		var now = $("#now").val();
		var pid = $("#pid").val();
		var zong = $("#zongye").val();
		if(parseInt(zong)>=parseInt(now)>0){
			window.location.href="../openingreport/add2_1.do?yeshu="+now+"&pid="+pid;
		}
		else{
			alert("输入有误");
			var yeshu = $("#yeshu").val();
			document.getElementById('now').value = yeshu;
		}
	}
	
	function f2(){
		var pid = $("#pid").val();
		window.location.href="../openingreport/add2_1.do?yeshu=1&pid="+pid;
	}
	
	function f5(){
		var zong = $("#zongye").val();
		var pid = $("#pid").val();
		window.location.href="../openingreport/add2_1.do?yeshu="+zong+"&pid="+pid;
	}
	
	function f3(){
		var now = $("#now").val();
		var pid = $("#pid").val();
		if(parseInt(now)==1){
			alert("已经是第一页");
		}
		else{
			var aa = parseInt(now)-1;
			window.location.href="../openingreport/add2_1.do?yeshu="+aa+"&pid="+pid;
		}
	}
	
	function f4(){
		var now = $("#now").val();
		var pid = $("#pid").val();
		var zong = $("#zongye").val();
		if(parseInt(zong)==parseInt(now)){
			alert("已经是最后一页");
		}
		else{
			var bb = parseInt(now)+1;
			window.location.href="../openingreport/add2_1.do?yeshu="+bb+"&pid="+pid;
		}
	}

</script>
<script>
function selectall() { 
	var tform = document.forms['form1']; 
	for (var i=0;i<tform.length;i++) 
	{ 
	var e = tform.elements[i]; 
	if (e.type == "checkbox") 
	e.checked = !e.checked; 
	} 
} 


</script>
